{literal}
  <script type="text/javascript">
<!--
function confirmDelete(articleId) {
if (confirm("This will Remove the authorisation setting. Continue?"))
  {/literal}
document.location = "{$pagename}&action=delete&id=" + articleId;
{literal}
}

function allowall()
{
  if (document.getElementById('allow').value == "Allow All")
  {
   {/literal} 
    {section name=pages loop=$numpages}
        document.getElementById('{if $page[pages].code == ""}{$page[pages].name}{else}{$page[pages].code}{/if}').checked=true;
    {/section}
    {literal}
    document.getElementById('allow').value = "Disallow All";
  }
  else if (document.getElementById('allow').value == "Disallow All")
  {
   {/literal} 
    {section name=pages loop=$numpages}
        document.getElementById('{if $page[pages].code == ""}{$page[pages].name}{else}{$page[pages].code}{/if}').checked=false;
    {/section}
    {literal}
    document.getElementById('allow').value = "Allow All";
  }
}
//-->
</script>
  {/literal}
{if $action!="edit" && $action!="new"}
{if $numauths > 0}
<h2>Authorization Settings</h2>
<div align="left"><input type="button" class="button" value="Set Authorization" onclick="window.location='{$pagename}&amp;action=new'" /></div>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
  <tr valign="top"> 
    <th width="10%" class="smallhead">Action</th>
    <th class="smallhead" width="30%">Name</th>
    <th class="smallhead">Type</th>
  </tr>
 {section name=front loop=$numauths}
	  <tr valign="middle"> 
		<td width="10%"  class="text"><a href="{$pagename}&amp;id={$auths[front].id}&amp;action=edit"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit Authorizations for {$auths[front].page}" title="Edit Authorizations for {$auths[front].page}" /></a> - <a href="javascript:confirmDelete({$auths[front].id})">
        <img src="{$tempdir}admin/images/delete.gif" border="0" alt="Remove Authorizations for {$auths[front].page}" title="Remove Authorizations for {$auths[front].page}" /></a></td>
		<td class="text"><div align="left">{$auths[front].authname}</div></td>
        <td class="text">{if $auths[front].type == 1}User Based{elseif $auths[front].type == 2}Group Based{elseif $auths[front].type == 3}Admin Panel Access Based{else}Unknown. Possibly pre-CMScout 1.10{/if}</td>
      </tr>  
    {/section}
</table>
{else}
<div align="center">No Authorization settings</div>
{/if}
<div align="left"><input type="button" class="button" value="Set Authorization" onclick="window.location='{$pagename}&amp;action=new'" /></div>
{elseif $action=="new" || $action=="edit"}
{if ($stage == 0 || $stage == "") && $action != "edit"}
    <form name="form" method="post" action="">
     Type of Authorisation: 
     <select name="type" id="type" class="inputbox">
      <option value="1">By user - Apply authorisation settings per user</option>
      <option value="2">By Group - Apply authorisation settings per group</option>
      <option value="3">By Access Level - Apply authorisation settings per administration access level</option>
     </select><br />
        <input type="hidden" name="stage" id="stage" value="1" />
        <input type="submit" name="Continue" value="Continue" class="button" />
        <input name="Cancel" type="button" id="Cancel" value="Cancel" onclick="history.go(-1);" class="button" />
    </form>
{elseif $stage == 1 || $action == "edit"}
    <form name="form2" method="post" action="">
    <table width = "100%">
    <tr><td class="text" align="left" colspan="2"><div align="left">
    <input type="hidden" name="type" id="type" value="{$type}" />
    {if $type == 1}
        Username:<select name="name" id="name" class="inputbox">
            {section name=thing loop=$numthings}
                <option value="{$things[thing].id}" {if $item.id == $things[thing].id}selected="selected"{/if}>{$things[thing].uname}</option>
            {/section}
        </select>
      {elseif $type == 2}
            Group:<select name="name" id="name" class="inputbox">
            {section name=thing loop=$numthings}
                <option value="{$things[thing].id}" {if $item.id == $things[thing].id}selected="selected"{/if}>{$things[thing].teamname}</option>
            {/section}
        </select>
    {elseif $type == 3}
            Access Level:<select name="name" id="name" class="inputbox">
            {section name=thing loop=$numthings}
                <option value="{$things[thing].id}" {if $item.id == $things[thing].id}selected="selected"{/if}>{$things[thing].name}</option>
            {/section}
        </select>
    {/if}  
            </div>
            </td>
    </tr>
          <tr>
          <td colspan="2" class="text"><div align="left"><input type="button" class="button" value="Allow All" onclick="allowall(this.form);" id="allow" /></div></td>
          </tr>
          {section name=pages loop=$numpages}
                    {if $page[pages].code != ""}
                       {assign var="name" value=$page[pages].code}
                    {else}
                       {assign var="name" value=$page[pages].name}
                    {/if}
                       <tr>
                <td align="right" class="text" width="20%"><div align="right">{if $page[pages].friendly == ""}{$page[pages].name}{else}{$page[pages].friendly}{/if}
</div></td>
                <td class="text"><div align="left"><input type="checkbox" name="{$page[pages].checkboxname}" id="{$page[pages].checkboxname}" value="1" {if $auths.$name == 1}checked="checked"{/if} />Allow Access</div></td>
            </tr>
         {/section}	
      </table>
      <p align="left">
        <input type="submit" name="Submit" value="Submit" class="button" />
         <input name="Cancel" type="button" id="Cancel" value="Cancel" onclick="window.history.go(-1);" class="button" />
       </p>
    </form>
{/if}
{/if}
<div align="center">
 <a href="http://www.cmscout.za.net/index.php?page=subsite&amp;site=Manual&amp;content=adminpanel-auth" target="_blank">Help</a>
</div>
